package com.zone.demo.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zone.demo.dto.Account;
import com.zone.demo.dto.User;
import com.zone.demo.domain.mapper.UserMapper;
import com.zone.demo.service.UserService;
import com.zone.demo.util.CurrentTime;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: SJP
 * Date: 2021/7/8
 * Time: 16:12
 * Description: No Description
 * @author SJP
 */

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    public static final int COUNT = 2000;
    @Override
    public void insertDataToUser() {

        for (int i = 0; i < COUNT; i++) {
            Date time = new CurrentTime().getCurrentTime();
            this.baseMapper.insertDataToUser(i,"li"+i,"男",i,time,time);
        }
    }

    @Override
    public void insertDataToAccount() {
        for (int i = 0; i < COUNT; i++) {
            Date time = new CurrentTime().getCurrentTime();
            this.baseMapper.insertDataToAccount(i,1000+i,"11011"+i,time,time);
        }
    }

    @Override
    public IPage<Account> getAllAccount(int current, int limit) {
        Page<Account> page = new Page<>(current, limit);
        return this.baseMapper.getAllAccount(page);
    }

    @Override
    public Account getAmountByName(String name) {
        return this.baseMapper.getAmountByName(name);
    }

    @Override
    public void createTableUser() {
        this.baseMapper.createTableUser();
    }

    @Override
    public IPage<User> getAllUser(int current,int limit) {
        Page<User> page = new Page<>(current, limit);
        return this.baseMapper.getAllUser(page);
    }

    @Override
    public void createTableAccount() {
        this.baseMapper.createTableAccount();
    }
}
